package com.fc.mall.service.impl;/**
 * Created by Administrator on 2019/9/19.
 */

import com.fc.mall.dao.UmsMemberAccountChangeHistoryDao;
import com.fc.mall.dto.UmsMemberAccountChangeHistory;
import com.fc.mall.dto.UmsMemberAccountChangeHistoryParm;
import com.fc.mall.service.UmsMemberAccountChangeHistoryService;
import com.fc.mall.util.Constants;
import com.fc.mall.util.Utils;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description TODO
 * @Author Climb
 * @Date 2019/9/19
 **/
@Service
public class UmsMemberAccountChangeHistoryServiceImpl implements UmsMemberAccountChangeHistoryService {
    @Autowired
    private UmsMemberAccountChangeHistoryDao umsMemberAccountChangeHistoryDao;

    @Override
    public List<UmsMemberAccountChangeHistory> queryList(UmsMemberAccountChangeHistoryParm parm, Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        List<UmsMemberAccountChangeHistory> accountChangeHistoryList = umsMemberAccountChangeHistoryDao.queryList(parm);
        accountChangeHistoryList.forEach(accountChangeHistory->{
            accountChangeHistory.setNickname(Utils.urlDecoderTransfer(accountChangeHistory.getNickname()));

            //账户类型为：购物佣金/提现奖励/手动增加 时金额变化类型显示“ + ”
            if (accountChangeHistory.getType().equals(Constants.AccountChangeType.ShoppingCommission.getValue()) ||
                    accountChangeHistory.getType().equals(Constants.AccountChangeType.WithdrawDepositReward.getValue()) ||
                    accountChangeHistory.getType().equals(Constants.AccountChangeType.ManualIncrease.getValue())){
                accountChangeHistory.setAmountChangeType("+");
            }else{
                accountChangeHistory.setAmountChangeType("-");
            }
        });
        return accountChangeHistoryList;
    }
}
